// 团队管理相关 API
import request from '@/utils/request';
import { PageResult } from '@/types/common';
import {
  TeamInfo,
  TeamCreateRequest,
  TeamUserCreateRequest,
  TeamPageQueryParams
} from '@/types/team';

export const teamApi = {
  // ============ 团队管理接口 ============
  
  // 创建团队
  createTeam(data: TeamCreateRequest): Promise<boolean> {
    return request.post('/admin/team/create', data);
  },

  // 更新团队信息
  updateTeam(data: TeamCreateRequest): Promise<boolean> {
    return request.post('/admin/team/update', data);
  },

  // 团队分页列表
  getTeamPageList(params: TeamPageQueryParams): Promise<PageResult<TeamInfo>> {
    return request.post('/admin/team/getPageList', params);
  },

  // 查看团队详细信息
  getTeamById(teamId: number): Promise<TeamInfo> {
    return request.post('/admin/team/getInfoById', null, {
      params: { teamId }
    });
  },

  // ============ 团队成员管理接口 ============
  
  // 添加团队成员
  addTeamUser(data: TeamUserCreateRequest): Promise<boolean> {
    return request.post('/admin/team/addTeamUser', data);
  },

  // 删除团队成员
  deleteTeamUser(id: number): Promise<boolean> {
    return request.post('/admin/team/delTeamUser', null, {
      params: { id }
    });
  },
};
